<template>
  <div class="tab-control">
    <div
      class="tab-item"
      :class="{active:index===i}"
      @click="itemClick(index)"
      v-for="(m,index) in titles"
      :key="index"
    >
      <span>{{m}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabControl",
  data() {
    return {
      i: 0
    };
  },
  props: {
    titles: {
      type: Array,
      default: []
    }
  },
  methods: {
    itemClick(index) {
      console.log("tabclick");
      this.i = index;
      this.$emit("itemClick", index);
    }
  }
};
</script>

<style scoped>
.tab-control {
  display: flex;
  text-align: center;
  font-size: 15px;
  height: 44px;
  line-height: 44px;
  z-index: 20;
}
.tab-item {
  flex: 1;
  margin: 0 38px;
}
.active {
  color: var(--color-tint);
  border-bottom: 3px solid var(--color-tint);
}
</style>
